package com.itfreer.cms.service.content;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.itfreer.cms.dao.content.SubjectDao;
import com.itfreer.cms.entity.content.SubjectEntity;
import com.itfreer.cms.service.content.SubjectService;
import com.itfreer.form.api.BaseDao;
import com.itfreer.form.api.imp.DictionaryServiceImp;
import com.itfreer.form.dictionary.base.DictionaryItem;

/**
 * 专题管理实现类
 */
@Component("subjectManageImp")
public class SubjectServicelmp extends DictionaryServiceImp<SubjectEntity> implements SubjectService {

	@Autowired
	private SubjectDao subjectDao;
	
	@Override
	protected BaseDao<SubjectEntity> getDao() {
		return subjectDao;
	}

	@Override
	public String getDictionaryName() {
		return "cms_subject";
	}

	@Override
	protected DictionaryItem convert(SubjectEntity entity) {
		DictionaryItem toEntity = new DictionaryItem();
		BeanUtils.copyProperties(entity, toEntity);
		toEntity.getOther().put("siteId", entity.getSiteId());
		toEntity.getOther().put("createDate", entity.getCreateDate());
		toEntity.getOther().put("recommend", entity.getRecommend());
		toEntity.getOther().put("image", entity.getImage());
		return toEntity;
	}

	@Override
	protected String getDictionaryFields() {
		return "id,pid,display,code,valid,leaf,siteId,createDate,recommend,image";
	}

}
